#-*- coding:utf-8 -*-

from models import UserImage

def save_upload_image(request, obj):

    if not request.user.is_authenticated():
        return False

    for imgid in request.POST.getlist('imgid', []):
        _imgid = int(imgid)
        try:
            img = UserImage.objects.get(id=_imgid)
            if request.user == img.user :
                img.content_object = obj
                img.save()
        except:
            print ">>>>>no object of id: ", _imgid

    return True

